Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TAS-1216] ✨ Define book cover for PDF file #457

Merged
merged 6 commits into from
Apr 9, 2024

Conversation

AuroraHuang22
Copy link
Collaborator

When a user uploads a PDF and a JPG/PNG image simultaneously, the first uploaded image should be set as the default cover image and written into the ISCN's thumbnail field.

QA flow:

  1. Navigate to /new to register an ISCN.
  2. Upload a PDF and an image.
  3. Complete the registration process.
  4. Verify in the downloaded JSON file if the thumbnail field has been populated.

Copy link

改善出版 PDF 功能

AuroraHuang22 added a commit that referenced this pull request Mar 18, 2024
AuroraHuang22 added a commit that referenced this pull request Mar 19, 2024
Comment on lines 826 to 833
for (const file of this.fileRecords) {
if (file.fileType === 'application/epub+zip') {
return false;
}
if (file.fileType === 'application/pdf') {
hasPDF = true;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use .find seems to be simpler, for of is required when the iterable is async

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 838 to 843
addToEpubMetadataList(ipfsHash: string, arweaveId: string) {
this.epubMetadataList.push({
thumbnailIpfsHash: ipfsHash,
thumbnailArweaveId: arweaveId,
})
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function doesn't seems necessary if it only has one line of content

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 858 to 863
if (
this.epubMetadataList[0] &&
this.epubMetadataList[0].thumbnailArweaveId
) {
return
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean if any thumbnailArweaveId exists for this.epubMetadataList we should return? If yes use .find

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 873 to 875
const transactionHash =
// eslint-disable-next-line no-await-in-loop
existingData.transactionHash || (await this.sendArweaveFeeTx(file))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer explicit if block if we are calling a function in the fallback case

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return
}
// eslint-disable-next-line no-restricted-syntax
for (const file of this.fileRecords) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer simple for loop if iterable is not async

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -837,6 +913,11 @@ export default class IscnUploadForm extends Vue {

try {
this.uploadStatus = 'uploading';

if (this.checkUploadFileTypeIsPDF()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the function does not simply check is PDF, but PDF and not EPUB, may be split 2 logic?
Sth like this.checkUploadFileTypeContainsPDF() && !this.checkUploadFileTypeContainsEPUB() (actually simple .find would do, we might not even need a function`

Copy link
Collaborator Author

@AuroraHuang22 AuroraHuang22 Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AuroraHuang22 added a commit that referenced this pull request Apr 9, 2024
@williamchong williamchong merged commit ecf299e into likecoin:main Apr 9, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants